package com.origin.grid.buy.controller.passport.connect;


import com.origin.grid.framework.common.enums.ResultUtil;
import com.origin.grid.framework.common.vo.ResultMessage;
import com.origin.grid.framework.modules.connect.service.ConnectService;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 买家端,app/小程序 联合登录
 *
 * @author Chopper
 * @since 2020-11-25 19:29
 */
@RestController
@Schema(name = "买家端,app/小程序 联合登录")
@RequestMapping("/buyer/passport/connect/bind")
public class ConnectBuyerBindController {

    @Autowired
    private ConnectService connectService;

    @Schema(name = "unionID 绑定")
    @Parameters({
           @Parameter(name = "unionID", description = "unionID", required = true, in = ParameterIn.QUERY),
           @Parameter(name = "type", description = "type", required = true, in = ParameterIn.QUERY)
    })
    @PostMapping
    public void unionIDBind(@RequestParam String unionID, @RequestParam String type) {
        connectService.bind(unionID, type);
    }

    @Schema(name = "unionID 解绑")
   @Parameter(name = "type", description = "type", required = true, in = ParameterIn.QUERY)
    @PostMapping("/unbind")
    public void unionIDBind(@RequestParam String type) {
        connectService.unbind(type);
    }


    @GetMapping("/list")
    @Schema(name = "绑定列表")
    public ResultMessage<List<String>> bindList() {
        return ResultUtil.data(connectService.bindList());
    }


}
